package com.hht.tools

import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.hht.baselibs.adapter.BaseDataAdapter
import com.hht.toolanduilibs.startActivity
import com.hht.tools.baselib.BaseLibsUI
import com.hht.tools.netlib.NetLibsUI
import com.hht.tools.touchlib.TouchLibsUI
import com.hht.tools.uilib.ToolsAndUiLibsUI
import com.hht.tools.uvc.UvcLibsUI

class MainActivity : AppCompatActivity() {
    private lateinit var mRecyclerView: RecyclerView
    private lateinit var mAdapter: BaseDataAdapter<String>
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        mRecyclerView = findViewById(R.id.root_recycle_view)
        initRecycleView()
    }

    private fun initRecycleView() {
        mRecyclerView.layoutManager = LinearLayoutManager(this)
        mAdapter = BaseDataAdapter<String>(R.layout.activity_main_item) { mView, value ->
            val textView = mView.findViewById<TextView>(R.id.text_view_item)
            textView.text = value
        }.setOnItemOnClickListener {
            val curList = mAdapter.getItemList()
            when (it) {
                curList[0] -> this.startActivity<BaseLibsUI>()

                curList[1] -> this.startActivity<ToolsAndUiLibsUI>()

                curList[2] -> this.startActivity<TouchLibsUI>()

                curList[3] -> this.startActivity<NetLibsUI>()

                curList[4] -> this.startActivity<UvcLibsUI>()
            }
        }.setAdapterData(getStringList())
        mRecyclerView.adapter = mAdapter
    }


    private fun getStringList(): List<String> {
        val list = mutableListOf<String>()
        list.add("BaseLibs")
        list.add("ToolAndUiLibs")
        list.add("TouchLibs")
        list.add("NetLibs")
        list.add("uvcLibs")
        return list
    }
}